#ifndef __SYSTEMSCHEDULER_H__
#define __SYSTEMSCHEDULER_H__

#if _MSC_VER > 1000
# pragma once
#endif

#include "System.h"
#include <ISystemScheduler.h>

class CSystemScheduler : public ISystemScheduler
{
public:
	CSystemScheduler(CSystem* pSystem);
	virtual ~CSystemScheduler(void);

	// ISystemScheduler
	VIRTUAL void SliceAndSleep(const char* sliceName, int line);
	VIRTUAL void SliceLoadingBegin();
	VIRTUAL void SliceLoadingEnd();

	VIRTUAL void SchedulingSleepIfNeeded(void);
	// ~ISystemScheduler

protected:
	void SchedulingModeUpdate(void);

private:
	CSystem* m_pSystem;
	ICVar* m_svSchedulingAffinity;
	ICVar* m_svSchedulingClientTimeout;
	ICVar* m_svSchedulingServerTimeout;
	ICVar* m_svSchedulingBucket;
	ICVar* m_svSchedulingMode;
	ICVar* m_svSliceLoadEnable;
	ICVar* m_svSliceLoadBudget;
	ICVar* m_svSliceLoadLogging;

	CTimeValue m_lastSliceCheckTime;

	int m_sliceLoadingRef;
};

// Summary:
//	 Creates the system scheduler interface.
void CreateSystemScheduler(CSystem* pSystem);

#endif //__SYSTEMSCHEDULER_H__